package base;

import java.util.Random;

public class 验证码 {
    public static void main(String[] args) {
        /*五位验证码，前四位为随机大小写英文字母，后一位为随机数字*/
        //创建一个字符串数组
        char [] chs = new char[52];
        //ASCII码表,英文字母导入数组
        for (int i = 0; i < chs.length; i++) {
            if (i <= 25){
                chs[i] = (char) (65+i); //大写
            }else {
                chs[i] = (char)(97+i-26); //小写
            }
        }//chs{........}

        //随机字母
//        Random r = new Random();
//        String resuft = "";
//        for (int i = 0; i < 4; i++) {
//            int randomindex = r.nextInt(chs.length);
//            resuft = resuft + chs[randomindex];
//        }
//        //随机数字
//        int randomnum = r.nextInt(10);
//        resuft = resuft + randomnum;
//        System.out.println("'"+resuft+"'");

        for (int j = 0; j < 10; j++) {
            //随机字母
            Random r = new Random();
            String resuft = "";
            for (int i = 0; i < 4; i++) {
                int randomindex = r.nextInt(chs.length);
                resuft = resuft + chs[randomindex];
            }
            //随机数字
            int randomnum = r.nextInt(10);
            resuft = resuft + randomnum;
            System.out.println("'"+resuft+"'");
        }

    }
}
